package test_38;

import java.util.PriorityQueue;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 张杰
 * Date: 2022-03-08
 * Time: 10:22
 */
public class test_38 {

    public static void main(String[] args) {
        TestHeap testHeap = new TestHeap();
        int[] array = {1,2,3,12,45,2};
        testHeap.creatBigHeap(array);
        testHeap.offer(7);
        System.out.println("=============");
        //System.out.println(testHeap.poll());
        System.out.println(testHeap.peek());
    }
    public static void main1(String[] args) {
        //默认小堆存储
        PriorityQueue<Integer> priorityQueue = new PriorityQueue<>();
        //每放一个元素，都得保证当前堆是 大堆 或者 小堆
        priorityQueue.offer(12);//每次入队的时候，都得保证当前是大堆或者小堆
        priorityQueue.offer(13);
        priorityQueue.offer(14);
        priorityQueue.offer(15);
        //System.out.println(priorityQueue.peek());
        System.out.println(priorityQueue.poll());//保证每次弹出一个元素之后，仍然是大根堆或者小根堆
        System.out.println(priorityQueue.poll());


    }
}
